package com.vca.admin.controller;


import com.vca.common.page.CommonPage;
import com.vca.common.request.PageParamRequest;
import com.vca.common.result.CommonResult;
import com.vca.common.vo.LineUpVo;
import com.vca.service.service.VcaLineUpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 排队登记表 前端控制器
 * </p>
 *
 * @author chenBing
 * @since 2022-11-24
 */
@Slf4j
@RestController("LineUpController")
@RequestMapping("api/admin/line/up")
@Api(tags = "排队登记")
public class LineUpController {
    @Autowired
    private VcaLineUpService vcaLineUpService;

    /**
     * @Description:排队管理列表
     * @Author: chenBing
     * @Date: 2022/11/25
     */
    @PreAuthorize("hasAuthority('admin:line:up:list')")
    @ApiOperation(value = "排队管理列表")
    @GetMapping(value = "/list")
    public CommonResult<CommonPage<LineUpVo>> list(
            @ApiParam(value = "用户昵称或用户ID")
            @RequestParam(value = "keyword", required = false) String keyword,
            @ApiParam(value = "类型 0=课程 1=套课 2=讲座 3=展览 4=全部")
            @RequestParam(value = "type", required = false) Integer type,
            @ApiParam(value = "通知状态 0=未通知 1=已通知 2=全部")
            @RequestParam(value = "noticeStatus", required = false) Integer noticeStatus,
            @ApiParam(value = "申请时间区间（yyyy-MM-dd,yyyy-MM-dd）")
            @RequestParam(value = "dateLimit", required = false) String dateLimit,
            @ModelAttribute PageParamRequest request
    ) {
        return CommonResult.success(CommonPage.restPage(vcaLineUpService.getLineUps(keyword, type, noticeStatus, dateLimit, request)));
    }

    /**
     * @Description:通知
     * @Author: chenBing
     * @Date: 2022/11/25
     */
    @PreAuthorize("hasAuthority('admin:line:up:notice')")
    @ApiOperation(value = "通知")
    @GetMapping(value = "/notice")
    public CommonResult<String> notice(
            @RequestParam(value = "lineUpIds") String lineUpIds
    ) {
        if (vcaLineUpService.notice(lineUpIds)) {
            return CommonResult.success();
        }
        return CommonResult.failed();
    }
}

